<template>
	<view>
		<dsl-navbar title="工作台" isBack bgTopImg="white" isicon=""></dsl-navbar>
		<view class="flex padding align-center ">
			<image :src="userIofo.avatar?userIofo.avatar:'/static/userImg.png'" mode="aspectFill"
				class="user_image animation-scale-up">
			</image>
			<view>
				<view>
					{{userIofo.nickname ||'人力公司'}}
				</view>
				<view class="flex align-center margin-top-sm">
					<view class="usre_authentication">企业认证</view>
					<!-- 	<view class="usre_bean margin-lr-sm">粉丝:36</view>
					<view class="usre_attention	">关注:565</view> -->
				</view>
			</view>
		</view>
		<view class="padding-lr ">
			<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
				<swiper-item v-for="(item,index ) in list" @click="preview(index,list)">
					<image :src="item" mode="aspectFill" class="swiper_image animation-scale-up"></image>
				</swiper-item>
			</swiper>
		</view>

		<!-- 公告 -->
		<view class="  " @click="$tools.push('/pages/plugins/announcement')">
			<view class="announcement2 rowsc">
				<image src="/static/icon/imgtongzhi.png" mode="" class=""></image>
				<view class="announcement_count2">
					<view v-if="messageList && messageList.length !=0">
						<swiper :indicator-dots="false" :vertical='true' :circular="true" :interval="3000"
							:duration="1000" autoplay="true" disable-touch="false" style="width: 500rpx;height: 50rpx;">
							<swiper-item v-for="(item,index) in messageList" class="align-center flex" :key='index'>
								<view class="onelineshow text-lg  margin-left flex align-center">
									<view>
										{{item.title ||'暂无公告'}}
									</view>
								</view>
							</swiper-item>
						</swiper>
					</view>
					<view v-else class="margin-left">
						暂无公告
					</view>
				</view>
			</view>
		</view>

		<view class=" text-center padding-lr flex flex-wrap ">
			<view v-for="(item,index) in applyList" :key='index' @click="pluginsMen(item,index)" style="width: 25%;"
				class="margin-top animation-scale-up">
				<image :src="item.icon" mode="widthFix" style="width: 96rpx;"></image>
				<view class="text-sm">{{item.title}}</view>
			</view>
		</view>
		<!-- 公告 -->
		<!-- 	<view class="announcement align-center " style="margin-top: 30rpx;box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.06);"
			@click="$tools.push('/pages/plugins/announcement')">
			<view class="solid-right margin-left padding-right  text-black" style="width: 110rpx;">
				<view class="announcement_text">源工智推</view>
			</view>
			<view class="margin-left-sm">
				<view class="align-center">
					<view class="announcement_round"></view>
					<view class="onelineshow announcement_title" v-if="getnoticeList[0]">{{getnoticeList[0].title}}
					</view>
				</view>
				<view class="align-center margin-top">
					<view class="announcement_round  "></view>
					<view class="onelineshow announcement_title" v-if="getnoticeList[1]">{{getnoticeList[1].title}}
					</view>
				</view>
			</view>
		</view> -->

		<view class="announcement align-center" style="margin-top: 30rpx;box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.06);"
			@click="$tools.push('/pages/workbench/modules/noticeList')">
			<view class="solid-right margin-left padding-right-sm">
				<image src="/static/zhitui.png" mode="" class="announcement_img"></image>
			</view>
			<view class="margin-left-sm">
				<view class="align-center">
					<view class="announcement_round"></view>
					<view class="onelineshow announcement_title">{{getnoticeList[0]?getnoticeList[0].title:''}}
					</view>
				</view>
				<view class="align-center margin-top">
					<view class="announcement_round  "></view>
					<view class="onelineshow announcement_title">{{getnoticeList[0]?getnoticeList[1].title:''}}
					</view>
				</view>
			</view>
		</view>
	<view class="rowsb padding align-center" @click="$tools.push('/pages/workbench/modules/videoList')">
			<view class="text-bold text-xl">
				研习社文章
			</view>
			<view class="text-gray text-sm">
				更多 <text class="cuIcon-right"></text>
			</view>
		</view>
		<view class="margin-tb" 
			v-if="carouselList && carouselList.length !=0">
			<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" class="workbench_image  "
				style="margin: 0 auto;">
				<swiper-item v-for="(item,index) in carouselList" :key='index'
				@click="$tools.push('/pages/workbench/modules/articleText?id='+item.id)">
					<image :src="item.big_title_image" mode="aspectFill" class="workbench_image"></image>
				</swiper-item>
			</swiper>
		</view>

		<view class="consult_body solid-bottom" v-for="(item,inedx) in articleList" :key="item.id"
			@click="$tools.push('/pages/workbench/modules/articleText?id='+item.id)">
			<view style="width: 440rpx;" class="lineshow3">{{item.title}}</view>
			<view>
				<image :src="item.title_image" mode="aspectFill" class="consult_image"></image>
			</view>
		</view>
		<view class="rowsb padding align-center" @click="$tools.push('/pages/workbench/modules/videoList')">
			<view class="text-bold text-xl">
				研习社视频
			</view>
			<view class="text-gray text-sm">
				更多 <text class="cuIcon-right"></text>
			</view>
		</view>
		<view class="flex flex-wrap rowsb padding-sm">
			<view class="video margin-bottom " v-for="(item,index) in videoList" :key="item.id"
				@click="videoSetMen(item.video)">
				<image :src="item.image" mode="aspectFill" style="width: 100%;height: 100%;"></image>
				<view class="play_video">
					<image src="/static/icon/bofang.png" mode="" style="width: 100%;height: 100%;"></image>
				</view>
			</view>
		</view>
		<view class="warp rowsc align-center" v-if="isVideoPlay">
			<view class="video-body ">
				<view class="rowsc">
					<video :src="videoValue" controls :autoplay='true'></video>
				</view>
				<view class="rowsc">
					<view class="video-close" @click="videoSetMen('')">
						关闭
					</view>
				</view>
			</view>
		</view>
	</view>
	 
</template>

<script>
	import {
		getnotice,
		getvideo,
		getarticle,
		articleWorkbench, //工作台研习社 
		getmessageUserList, //接收人人看到的公告
		getUserInfo,//人力信息
	} from '../../common/path.js'
	import {
		preview
	} from '../../common/updataImgList.js'
	export default {
		data() {
			return {
				list: [
					'https://img1.baidu.com/it/u=2694854021,4266983240&fm=26&fmt=auto'
				],
				isVideoPlay: false, //视频弹窗
				videoValue: '', //播放的视频
				userIofo: '',
				applyList: [{
						icon: '/static/workbench/imgdaiye.png',
						title: '我的员工',
						toUrl: '/pages/enterprise/staff/staff?id=221',
						id: 1
					},
					{
						icon: '/static/workbench/imgqiye.png',
						title: '用工企业',
						toUrl: '/pages/enterprise/laborEmployer?id=2',
						id: 2
					},
					{
						icon: '/static/workbench/imgfuwu.png',
						title: '服务费',
						toUrl: 'modules/serve_cost?id=1',
						id: 3
					},
					{
						icon: '/static/workbench/imgruzhi.png',
						title: '保入职',
						toUrl: 'modules/await_industry?id=40',
						id: 40
					},
					{
						icon: '/static/workbench/imgrencaiku.png',
						title: '人才库',
						toUrl: 'modules/await_industry?id=50',
						id: 50
					},
					// {
					// 	icon: '/static/workbench/imgdaiye.png',
					// 	title: '待业中',
					// 	toUrl: 'modules/await_industry?id=6',
					// 	id: 6
					// },
					{
						icon: '/static/workbench/imgruzhi-2.png',
						title: '已入职',
						toUrl: 'modules/await_industry?id=3',
						id: 3
					},
					{
						icon: '/static/workbench/imgtongguo.png',
						title: '未通过',
						toUrl: 'modules/await_industry?id=5',
						id: 5
					},
					{
						icon: '/static/workbench/imglizhi.png',
						title: '离职',
						toUrl: 'modules/await_industry?id=4',
						id: 4
					},
					{
						icon: '/static/workbench/imgmianshi.png',
						title: '待面试',
						toUrl: 'modules/await_industry?id=1',
						id: 1
					},
					{
						icon: '/static/workbench/imgruzhi-3.png',
						title: '待入职',
						toUrl: 'modules/await_industry?id=2',
						id: 2
					},
					{
						icon: '/static/workbench/imgquanbu.png',
						title: '全部',
						toUrl: 'modules/await_industry?id=12',
						id: 12
					},
					{
						icon: '/static/workbench/icon_qysh.png',
						title: '权益生活		',
						toUrl: 'modules/await_industry?id=2',
						id: 2
					},
				],
				getnoticeList: [], //源工智推
				pageData: 1, //第一页
				videoList: [], //视频
				articleList: [], //文章
				title_image: '', //测试数据
				messageList: [], //公告列表
				carouselList: [], //多图
			}
		},
		onShow() {
			this.getnotice() // 公告
			this.getvideo() //视频列表
			this.getarticle() //文章列表
			this.getmessageUserList() //接收人看到的公告
			this.getUserInfo(); //用户信息
		},
		methods: {
			
			//用户信息
			getUserInfo() {
				this.Http.POST(getUserInfo, {})
					.then(res => {
						if (res.code == 1) {
							console.log('[用户信息]', res);
							this.userIofo = res.data
							uni.setStorageSync('userIofo', res.data)
						} else {
							this.userIofo = 0
							this.$tools.showToast(res.msg)
						}
					})
			},
			preview(a, i) {
				preview(0, i)
			},
			//接收人看到的公告
			getmessageUserList() {
				let data = {
					page: 1,
					listrows: 9999
				}
				this.Http.POST(getmessageUserList, data)
					.then((res) => {
						if (res.code == 1) {
							// console.log('[公告列表]', res);
							this.messageList = res.data

						}
					})
			},



			//功能
			pluginsMen(item, index) {
				this.$tools.push(item.toUrl + '&title=' + item.title)
			},

			//关闭弹窗
			videoSetMen(item) {
				this.isVideoPlay = !this.isVideoPlay
				this.videoValue = item
			},
			//文章
			getarticle() {
				//工作台研习社
				let datas = {
					status: 1
				}
				this.Http.POST(articleWorkbench, datas)
					.then((res) => {
						// console.log('[工作台研习社]', res);
						if (res.code == 1) {
							this.carouselList = res.data.carousel
							this.articleList = res.data.recommend
						}
					})

				return
				//全部研习社
				let data = {
					status: 1,
					page: 1,
					listrows: 20,
				}

				this.Http.POST(getarticle, data)
					.then((res) => {
						if (res.code == 1) {
							this.articleList = res.data
							this.title_image = res.data[0].title_image
						} else {
							this.articleList = []
						}
					})
			},
			//智能消息
			getnotice() {
				let data = {}
				this.Http.POST(getnotice, data)
					.then(res => {
						// console.log('[智能消息]', res);
						if (res.code == 1) {
							this.getnoticeList = res.data
						} else {
							this.$tools.showToast(res.msg)
						}
					})
			},
			//视频列表
			getvideo() {
				let data = {
					status: 1,
					page: this.pageData,
					listrows: 10
				}
				this.Http.POST(getvideo, data)
					.then((res) => {
						// console.log('[视频列表]', res);
						if (res.code == 1) {
							if (this.pageData == 1) {
								this.videoList = res.data
							} else {
								this.videoList.push(...res.data)
							}
						} else {
							if (this.pageData == 1) {
								this.videoList = []
							} else {
								this.$tools.showToast('暂无更多内容')
							}
						}
					})
			},
			onReachBottom(e) {
				this.pageData++
				this.getvideo()
			},
		}
	}
</script>

<style lang="scss" scoped>
	.announcement_text {
		font-size: 32rpx;
		font-weight: 1000;
	}

	/* 公告 */
	.announcement {
		width: 750rpx;
		opacity: 1;
		display: flex;
		align-items: center;
		padding: 30rpx;
	}

	.announcement>image {
		width: 33rpx;
		height: 33rpx;
		opacity: 1;
		margin-right: -20rpx;
	}
	.announcement2{
		display: flex;
		align-items: center;
		margin: 0 30rpx;
		position: relative;
	} 
	.announcement2>image {
		width: 33rpx;
		height: 33rpx;
		opacity: 1;
		position: absolute;
		left: 30rpx;
	}
	.announcement_count2 {
	
		height: 100rpx;
		width: 100%;
		background: #F3F3F4;
		font-size: 24rpx;
		display: flex;
		align-items: center;
		padding-left: 70rpx;
		border-radius: 0rpx 0rpx  20rpx 20rpx;
		
	}
	.announcement_count {
		width: 658rpx;
		height: 100rpx;
		background: #F3F3F4;
		border-radius: 20rpx;
		font-size: 24rpx;
		display: flex;
		align-items: center;
		padding-left: 40rpx;
		margin-left: -30rpx;
	}

	.user_image {
		width: 119rpx;
		height: 119rpx;
		// background: #323836;
		border-radius: 50%;
		opacity: 1;
		margin-right: 20rpx;
	}

	.usre_authentication {
		width: 120rpx;
		height: 32rpx;
		border: 1rpx solid #00D88F;
		opacity: 1;
		border-radius: 20rpx;
		font-size: 20rpx;
		font-family: PingFang SC;
		font-weight: 400;
		line-height: 32rpx;
		color: #00D88F;
		opacity: 1;
		text-align: center;

	}

	.usre_bean {
		height: 32rpx;
		background: #00D88F;
		opacity: 1;
		border-radius: 32rpx;
		padding-left: 20rpx;
		padding-right: 20rpx;
		text-align: center;
		color: white;
		font-size: 20rpx;
	}

	.usre_attention {
		height: 32rpx;
		background: #00D88F;
		opacity: 1;
		border-radius: 32rpx;
		padding-left: 20rpx;
		padding-right: 20rpx;
		text-align: center;
		color: white;
		font-size: 20rpx;
	}

	.swiper_image {
		width: 690rpx;
		height: 300rpx;
		background: #07D6C6;
		opacity: 1;
		border-radius: 20rpx 20rpx 0 0 ;
		width: 100%;
	}


	// 底部新闻咨询
	.workbench_image {
		width: 690rpx;
		height: 260rpx;
		opacity: 1;
		border-radius: 10px;
	}

	.consult_body {
		display: flex;
		padding: 30rpx;
		justify-content: space-between;

	}

	.consult_image {
		width: 230rpx;
		height: 160rpx;
		background: #D5E4EA;
		opacity: 1;
		border-radius: 10rpx;
	}

	/* 公告 */
	.announcement {
		width: 710rpx;
		background: #FFFFFF;
		// box-shadow: 0px 0px 20rpx rgba(0, 0, 0, 0.06);
		border-radius: 20rpx;
		margin: 0 auto;
	}

	.announcement_img {
		width: 63rpx;
		height: 70rpx;
	}

	.announcement_round {
		width: 10rpx;
		height: 10rpx;
		background: #00D88F;
		border-radius: 50%;
	}

	.announcement_title {
		width: 480rpx;
		height: 33rpx;
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 400;
		color: #3D444D;
		opacity: 1;
		margin-left: 15rpx;
	}

	// 视频
	.video {
		width: 337rpx;
		height: 189rpx;
		background: #FFFFFF;
		box-shadow: 0px 0px 20rpx rgba(51, 51, 51, 0.1);
		border-radius: 16rpx;
		overflow: hidden;
		// overflow: hidden;
		position: relative;

		.play_video {
			height: 60rpx;
			width: 60rpx;
			position: absolute;
			top: 60rpx;
			margin: 0 auto;
			left: 0;
			right: 0;
		}

		.video_title {
			width: 306rpx;
			font-size: 26rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #333333;
			opacity: 1;
		}
	}

	page {
		padding-bottom: 120rpx;
	}

	.video-body {
		video {
			border-radius: 20rpx;
			height: 1000rpx;
			width: 700rpx;
		}

		.video-close {
			border: 1rpx solid white;
			color: white;
			padding: 10rpx 35rpx;
			border-radius: 30rpx;
			margin-top: 30rpx;
		}
	}
</style>
